package org.ctgu.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.ctgu.entity.Employee;
import org.ctgu.entity.dto.EmployeePageQueryDTO;
import org.ctgu.mapper.EmployeeMapper;
import org.ctgu.result.PageResult;
import org.ctgu.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    /**
     * 维修人员分页查询
     *
     * @param employeePageQueryDTO
     * @return
     */
    public PageResult page(EmployeePageQueryDTO employeePageQueryDTO) {
        PageHelper.startPage(employeePageQueryDTO.getPage(), employeePageQueryDTO.getPageSize());

        Page<Employee> page = employeeMapper.page(employeePageQueryDTO);
        long total = page.getTotal();
        List<Employee> records = page.getResult();
        return new PageResult(total, records);
    }
}
